package com.eatme.web.sys.quartz.job;

import org.apache.commons.lang3.time.DateFormatUtils;
import org.quartz.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.Date;

/**
 * 不带参的简单定时任务
 */
// 防止并发
// @DisallowConcurrentExecution
// 更新 jobDataMap
// @PersistJobDataAfterExecution
public class AppJob implements Job {

	public AppJob() {

	}

	private int count;

	public int getCount() {
		return count;
	}

	public void setCount(int count) {
		this.count = count;
	}

	// job传递参数 示例
	// 通过 get set 方法获取参数
//	private String name;
//
//	public String getName() {
//		return name;
//	}
//
//	public void setName(String name) {
//		this.name = name;
//	}

	private static final Logger LOG = LoggerFactory.getLogger(AppJob.class);

	@Override
	public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {

//		count++;
//		jobExecutionContext.getJobDetail().getJobDataMap().get(count);

//		jobExecutionContext.getTrigger();
//		jobExecutionContext.getNextFireTime();
//		jobExecutionContext.getJobDetail();
		// job获取传入参数
//		JobDataMap map = jobExecutionContext.getJobDetail().getJobDataMap();
		LOG.info("时间: {},线程 {},App 的普通定时任务AppJob正在执行,count值: {}",Thread.currentThread().getName(),DateFormatUtils.format(new Date(),DateFormatUtils.ISO_DATETIME_FORMAT.getPattern()),count);
	}
}
